package cn.mothin.frame.core.interfaces;

import java.util.List;
import java.util.Map;

import cn.mothin.frame.core.interfaces.vo.IQueryPage;

public interface ISqlHelper {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#execute(java.lang.String,
	 * java.lang.Object)
	 */
	public abstract void execute(String sql, Object... params);

	/**
	 * 查询数目，一般应对 select count 操作
	 * 
	 * @param sql
	 * @param args
	 * @return
	 */
	public abstract long queryCount(String sql, Object... args);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#queryForList(java.lang.String,
	 * java.lang.Object)
	 */
	public abstract List<Map<String, Object>> queryForList(String sql,
			Object... args);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#insert(java.lang.Object)
	 */
	public abstract void insert(Object object);

	public abstract void delete(Object object);

	public abstract void insertOrUpdate(Object object);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#update(java.lang.Object,
	 * java.lang.String)
	 */
	public abstract void update(Object object, String... fieldNames);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#insert(java.lang.String,
	 * java.lang.String)
	 */
	public abstract void insert(String tableName, String json);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#update(java.lang.String,
	 * java.lang.String, java.lang.String)
	 */
	public abstract void update(String tableName, String id, String json);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#delete(java.lang.String,
	 * java.lang.String)
	 */
	public abstract void delete(String tableName, String id);

	public abstract <T> List<T> query(Class<T> c, String sql, Object... args);

	public abstract <T> List<T> queryForList(Class<T> c, String sql,
			Object... args);

	public abstract <T> T queryForObject(Class<T> c, String sql, Object... args);

	public abstract Map<String, Object> queryForMap(String sql, Object... args);

	public abstract String queryForMapJson(String sql, Object... args);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.njyiz.frame.core.db.ISqlHelp#queryJson(java.lang.String,
	 * java.lang.Object)
	 */
	public abstract String queryJson(String sql, Object... args);

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.njyiz.frame.core.db.ISqlHelp#queryJson(com.njyiz.frame.core.db.IQueryPage
	 * , java.lang.String, java.lang.Object)
	 */
	public abstract String queryJson(IQueryPage page, String sql,
			Object... values);
	
	public Map<String, Object> queryAll(IQueryPage page, String sql, final Object... values);
	
	public byte[] queryAllForExport(IQueryPage page, String sql, final Object... values);

}